<%--
  Created by IntelliJ IDEA.
  User: 28912
  Date: 2022/11/6
  Time: 10:23
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="en">
<head>
  <link rel="stylesheet" type="text/css" href="../../../web_01-1.0-SNAPSHOT/static/css/web_01.css"/>
  <meta charset="UTF-8">
  <title>stulog</title>
</head>
<body>
<div class="login_banner">
  <div id="l_content">
    <span class="login_word">学生信息管理系统</span>
  </div>
  <div id="content">
    <div class="login_form">
      <div class="login_box">
        <div class="tit">
          <h1>账号为学号！</h1>
          <a href="selog.jsp">管理员登录</a>
        </div>
        <div class="msg_cont">
          <b></b>
          <span class="errorMsg" id="error02">请输入账号和密码</span>
        </div>
        <div class="form">
          <form method="post">
            学生账号：
              <input class="itxt" type="text" id="u_id" placeholder="请输入账号" name="username" />
            <br />
            <br />
            学生密码：
              <input class="itxt" type="password" id="u_pwd" placeholder="请输入密码" name="password" />
            <br />
            <br />
            <button id="sub_btn">登录</button>
            <span class="errorMsg" id="error03">${error}</span>
          </form>
          <script language="JavaScript">
            let but01 = document.getElementById("sub_btn");
            but01.onclick = function (){
              let gid = document.getElementById("u_id").value;
              let patt = /^\w{5,12}$/;
              if(gid==null||gid===""){
                document.getElementById("error02").innerHTML = "账号不能为空！"
                return false;
              }
              let gpwd = document.getElementById("u_pwd").value;
              if(gpwd==null||gpwd===""){
                document.getElementById("error02").innerHTML = "密码不能为空!"
                return false;
              }else if(!patt.test(gpwd)){
                document.getElementById("error03").innerHTML = "密码必须由字母数字下划线组成且长度在5到12位！"
                return false;
              }
              //超链接访问servlet并带参数   注意返回值参数的类型！！！
              window.location.href = "/web/sulogin?id="+gid+"&pwd="+gpwd;
              return false;
            }
          </script>
        </div>
      </div>
    </div>
  </div>
</div>
</body>
</html>
